import Vue from 'vue'
import store from '@/store'

/**权限指令**/
Vue.directive('has', {
  bind: function (el, binding) {
    if (!Vue.prototype.$_has(binding.value)) {
      // el.parentNode.removeChild(el);
      el.style.display = 'none';
    }
  }
});
//权限检查方法
Vue.prototype.$_has = function (value) {
  let isExist = false;
  
  let buttonperms = store.state.user_info.btns
  // 权限列表
  for (let i = 0; i < buttonperms.length; i++) {
    if (buttonperms[i] === value) {
      isExist = true;
      break;
    }
  }
  return isExist;
};